<template>
  <div id="app">
    <keep-alive include="bindWechat_unbind">
      <router-view />
    </keep-alive>
  </div>
</template>
<script>
import { Login } from '@/api/login';
import messageMixin from '@/mixins/messageMixin';
import messageBoxMixin from '@/mixins/messageBoxMixin';
import { createNamespacedHelpers } from 'vuex';
import { setToken } from '@/utils/request';

const { mapState, mapMutations } = createNamespacedHelpers('login');
export default {
  name: 'app',
  components: {},
  mixins: [messageMixin, messageBoxMixin],
  computed: mapState(['userInfo']),
  methods: {
    // 更新用户信息
    ...mapMutations(['updateUserInfo']),
  },
  created() {
    if (process.env.NODE_ENV === 'development') {
      setToken(
        'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHQiOjE3NjQyOTk4MTU1MjgsInVpZCI6IjZkNjAyMzJkN2E4NjQxODE5YmQ3M2VkMTY3ZWQxOTc4IiwiaWF0IjoxNzYzNjk1MDE1NTI4fQ.aDN3uCLFzIaDzSuMDmSGHXp89k0nWiEsXWCRtYGqo7Q',
      );
    } else {
      setToken();
    }
    Login({ request_from_page: 'app' }).then((res) => {
      this.$store.commit('login/updateUserInfo', res);
      this.$store.commit('login/setIsSendSystemGift', res.isSendSystemGift);
      console.log('***res***', res);
    });
  },
  mounted() {},
};
</script>
<style lang="less">
/* 全局样式 */
* {
  margin: 0;
  padding: 0;
}
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
}
a {
  text-decoration: none;
}
div {
  box-sizing: border-box;
}
.card {
  background: #ffffff;
  box-shadow: 2px 3px 9px 0 rgba(119, 119, 119, 0.1);
  border-radius: 4px;
}
</style>
